<html>
<head>
    <title>移动教学信息管理系统 - 后台</title>
    <link href="/static/css/semantic.css" rel="stylesheet"/>
    <style>
body{font-family: "Microsoft YaHei" !important;}
body {
    background-color: #FFFFFF;
}
.ui.menu .item img.logo {
    margin-right: 1.5em;
}
.main.container {
    margin-top: 7em;
}
.wireframe {
    margin-top: 2em;
}
.ui.footer.segment {
    margin: 5em 0em 0em;
    padding: 5em 0em;
}
    </style>
</head>
<body>
    <table class="ui celled striped table">
        <thead>
        <tr><th colspan="4">学生管理
            <button class="button ui primary" onclick="$('.ui.modal').modal('show');">添加</button>
        </th>
        </tr>
        <tr>
            <th>ID</th>
            <th>姓名</th>
            <th>用户名</th>
            <th>性别</th>
            <th>专业</th>
        </tr>
        </thead>
        <tbody>

        <#list list as i>
        <tr>
            <td class="collapsing"> ${i.id} </td>
            <td>${i.name!}</td>
            <td>${i.username!}</td>
            <td>${i.sex!}</td>
            <td>${i.prof!}</td>
            <td class="right aligned collapsing">
                <button class="button ui orange" onclick="$('.ui.modal').modal('show');onUpdate('${i.id!}','${i.name!}','${i.username!}','${i.sex!}','${i.prof!}')">修改</button>
                <button class="button ui red" onclick="del('${i.id}')">删除</button>
            </td>
        </tr>
        </#list>
        </tbody>
    </table>
<div class="ui modal" style="width: 300px; padding: 15px;margin-left: -200px">
    <form class="ui form five" method="post" action="/user/add" form-ajax forward=" ">
        <input type="hidden" name="id"/>
        <input type="hidden" name="type" value="2"/>
        <div class="field">
            <input type="text" name="name" placeholder="姓名">
        </div>
        <div class="field">
            <input type="text" name="username" placeholder="用户名">
        </div>
        <div class="field">
            <input type="text" name="sex" placeholder="性别">
        </div>
        <div class="field">
            <input type="text" name="prof" placeholder="专业">
        </div>
        <button class="ui button primary" type="submit">提交</button>
        <button class="ui button" type="button" onclick="$('.ui.modal').modal('hide');">取消</button>
    </form>
</div>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/semantic.min.js"></script>
<script type="text/javascript" src="/static/js/form-ajax.js"></script>
<script type="text/javascript" src="/static/js/jquery.validate.min.js"></script>
<script type="text/javascript">
function onUpdate(id,name,username,sex,prof) {
    $('input[name=id]').val(id);
    $('input[name=name]').val(name);
    $('input[name=username]').val(username);
    $('input[name=sex]').val(sex);
    $('input[name=prof]').val(prof);
}
function del(id) {
    $.post('/user/delete/'+id,function (data) {
        alert('删除成功');
        location.reload();
    })
}
</script>
</body>
</html>